import 'package:flutter/material.dart';
import 'package:note_app/providers/hide_play_button_provider.dart';
import 'package:note_app/providers/theme_provider.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
import 'dart:io';

class SettingsScreen extends StatefulWidget {
  @override
  _SettingsScreenState createState() => _SettingsScreenState();
}

class _SettingsScreenState extends State<SettingsScreen> {
  String? appName;
  String? packageName;
  String? version;
  String? buildNumber;

  @override
  void initState() {
    super.initState();
    PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
      setState(() {
        appName = packageInfo.appName;
        packageName = packageInfo.packageName;
        version = packageInfo.version;
        buildNumber = packageInfo.buildNumber;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    final checkTheme = Provider.of<ThemeProvider>(context);
    final checkButtonState = Provider.of<HidePlayButtonProvider>(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('设置'),
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
        child: Center(
          child: Container(
            child: Column(
              children: [
                SingleChildScrollView(
                  child: Column(
                    children: [
                      Container(
                        child: Column(
                          children: [
                            Text(
                              '识文哔哔机',
                              style: TextStyle(
                                fontSize: 30,
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                            SizedBox(
                              height: 10,
                            ),
                            Text(
                              '识文哔哔机在你需要的时候，迅速地将文字转换为音频。有了这个程序，您的手机可以成为你的可靠助手。',
                              style: TextStyle(),
                              textAlign: TextAlign.center,
                            )
                          ],
                        ),
                      ),
                      SizedBox(
                        height: 10,
                      ),
                      ListTile(
                        leading: Icon(checkTheme.mTheme == false
                            ? Icons.brightness_3
                            : Icons.brightness_6),
                        title: Text(
                          '夜间模式',
                          style: TextStyle(),
                        ),
                        subtitle: Text('切换日间夜间模式'),
                        trailing: Switch(
                          value: checkTheme.mTheme,
                          onChanged: (val) {
                            checkTheme.checkTheme();
                          },
                        ),
                      ),
                      SizedBox(
                        height: 10,
                      ),
                      ListTile(
                        leading: Icon(Icons.play_arrow),
                        title: Text(
                          '隐藏阅读按钮',
                          style: TextStyle(),
                        ),
                        subtitle: Text('开启后隐藏笔记详情的辅助阅读按钮'),
                        trailing: Switch(
                          value: checkButtonState.mPlayButton,
                          onChanged: (val) {
                            checkButtonState.checkButtonState();
                          },
                        ),
                      ),
                      SizedBox(
                        height: 10,
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
